
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>二、关键字 · 计算机笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="海拉尔的三角">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro-fixed/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-ancre-navigation/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-insert-logo-link-website/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-prism/prism-tomorrow.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-flexible-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-lightbox/css/lightbox.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-auto-scroll-table/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-katex-pro/katex.min.css">
                
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-terminull-light/terminull.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="point_reference_withNum.html" />
    
    
    <link rel="prev" href="foundation_withNum.html" />
    

    
        <link rel="shortcut icon" href="image/ico.png" type="image/x-icon">
    
    
    
    
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="image/ico.png">
    
    
        
    
    
        
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://github.com/spite-triangle" target="_blank" class="custom-link">Github</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../cpp.html">
            
                <a href="../cpp.html">
            
                    
                    C/C++
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1.1" data-path="foundation_withNum.html">
            
                <a href="foundation_withNum.html">
            
                    
                    一、基础概念
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.1.2" data-path="keyword_withNum.html">
            
                <a href="keyword_withNum.html">
            
                    
                    二、关键字
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.3" data-path="point_reference_withNum.html">
            
                <a href="point_reference_withNum.html">
            
                    
                    三、指针与引用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.4" data-path="oop_withNum.html">
            
                <a href="oop_withNum.html">
            
                    
                    四、面向对象
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.5" data-path="memory_withNum.html">
            
                <a href="memory_withNum.html">
            
                    
                    五、内存
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.6" data-path="process_withNum.html">
            
                <a href="process_withNum.html">
            
                    
                    六、进程与线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.7" data-path="locks_withNum.html">
            
                <a href="locks_withNum.html">
            
                    
                    七、锁
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.8" data-path="stl_withNum.html">
            
                <a href="stl_withNum.html">
            
                    
                    八、STL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.9" data-path="dataStruction_withNum.html">
            
                <a href="dataStruction_withNum.html">
            
                    
                    九、数据结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.10" data-path="array_list_withNum.html">
            
                <a href="array_list_withNum.html">
            
                    
                    十、数组链表操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.11" data-path="find_withNum.html">
            
                <a href="find_withNum.html">
            
                    
                    十一、目标查找
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.12" data-path="tree_withNum.html">
            
                <a href="tree_withNum.html">
            
                    
                    十二、树
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.13" data-path="binaryTree_withNum.html">
            
                <a href="binaryTree_withNum.html">
            
                    
                    十三、二叉树
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.14" data-path="dynamicProgram_withNum.html">
            
                <a href="dynamicProgram_withNum.html">
            
                    
                    十四、动态规划
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.15" data-path="backtracking_withNum.html">
            
                <a href="backtracking_withNum.html">
            
                    
                    十五、回溯算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.16" data-path="monotoneStack_withNum.html">
            
                <a href="monotoneStack_withNum.html">
            
                    
                    十六、单调栈
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.1.17" data-path="toollib_withNum.html">
            
                <a href="toollib_withNum.html">
            
                    
                    附录 工具库
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../../MySQL/mysql.html">
            
                <a href="../../MySQL/mysql.html">
            
                    
                    MySQL
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1.1" data-path="../../MySQL/chapter/introduction_withNum.html">
            
                <a href="../../MySQL/chapter/introduction_withNum.html">
            
                    
                    一、简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.2" data-path="../../MySQL/chapter/foundation_withNum.html">
            
                <a href="../../MySQL/chapter/foundation_withNum.html">
            
                    
                    二、控制台操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.3" data-path="../../MySQL/chapter/operatorDB_withNum.html">
            
                <a href="../../MySQL/chapter/operatorDB_withNum.html">
            
                    
                    三、数据库、表操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.4" data-path="../../MySQL/chapter/operatorData_withNum.html">
            
                <a href="../../MySQL/chapter/operatorData_withNum.html">
            
                    
                    四、数据操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.5" data-path="../../MySQL/chapter/transaction_withNum.html">
            
                <a href="../../MySQL/chapter/transaction_withNum.html">
            
                    
                    五、事务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.6" data-path="../../MySQL/chapter/index_withNum.html">
            
                <a href="../../MySQL/chapter/index_withNum.html">
            
                    
                    六、索引
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.7" data-path="../../MySQL/chapter/authority_withNum.html">
            
                <a href="../../MySQL/chapter/authority_withNum.html">
            
                    
                    七、权限管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.8" data-path="../../MySQL/chapter/backup_withNum.html">
            
                <a href="../../MySQL/chapter/backup_withNum.html">
            
                    
                    八、备份
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../../linux/linux.html">
            
                <a href="../../linux/linux.html">
            
                    
                    Linux
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1.1" data-path="../../linux/chapter/foundation_withNum.html">
            
                <a href="../../linux/chapter/foundation_withNum.html">
            
                    
                    一、原理知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.1.2" data-path="../../linux/chapter/command_withNum.html">
            
                <a href="../../linux/chapter/command_withNum.html">
            
                    
                    二、指令
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="divider"></li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../../tcp_udp/tcp_upd.html">
            
                <a href="../../tcp_udp/tcp_upd.html">
            
                    
                    网络
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1.1" data-path="../../tcp_udp/chapter/foundation_withNum.html">
            
                <a href="../../tcp_udp/chapter/foundation_withNum.html">
            
                    
                    一、网络通讯基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.1.2" data-path="../../tcp_udp/chapter/tcp_udp_withNum.html">
            
                <a href="../../tcp_udp/chapter/tcp_udp_withNum.html">
            
                    
                    二、tcp/udp
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >二、关键字</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-anchor"></i><ul><li><span class="title-icon "></span><a href="#&#x5173;&#x952E;&#x5B57;"><b></b>&#x5173;&#x952E;&#x5B57;</a></li><li><span class="title-icon "></span><a href="#1-newdelete"><b></b>1. new/delete</a></li><li><span class="title-icon "></span><a href="#2-const"><b></b>2. const</a></li><li><span class="title-icon "></span><a href="#3-override"><b></b>3. override</a></li><li><span class="title-icon "></span><a href="#4-volatile"><b></b>4. volatile</a></li><li><span class="title-icon "></span><a href="#5-static"><b></b>5. static</a></li><li><span class="title-icon "></span><a href="#6--extern-c"><b></b>6.  extern &quot;C&quot;</a></li><li><span class="title-icon "></span><a href="#7--extern"><b></b>7.  extern</a></li><li><span class="title-icon "></span><a href="#8--friend"><b></b>8.  friend</a></li><li><span class="title-icon "></span><a href="#9--&#x50A8;&#x5B58;&#x7C7B;&#x578B;&#x7B26;"><b></b>9.  &#x50A8;&#x5B58;&#x7C7B;&#x578B;&#x7B26;</a></li><li><span class="title-icon "></span><a href="#10--cin"><b></b>10.  cin</a></li><ul><li><span class="title-icon "></span><a href="#101-&#x7B80;&#x4ECB;"><b></b>10.1. &#x7B80;&#x4ECB;</a></li><li><span class="title-icon "></span><a href="#102-&#x7528;&#x6CD5;"><b></b>10.2. &#x7528;&#x6CD5;</a></li><ul><li><span class="title-icon "></span><a href="#1021-cin-"><b></b>10.2.1. cin &gt;&gt;</a></li><li><span class="title-icon "></span><a href="#1022--cinget"><b></b>10.2.2.  cin.get()</a></li><li><span class="title-icon "></span><a href="#1023-cingetline&#xFF08;&#xFF09;--&#x8BFB;&#x53D6;&#x884C;"><b></b>10.2.3. cin.getline&#xFF08;&#xFF09;  &#x8BFB;&#x53D6;&#x884C;</a></li></ul><li><span class="title-icon "></span><a href="#103-cin-&#x6E05;&#x7A7A;&#x8F93;&#x5165;&#x7F13;&#x51B2;&#x533A;"><b></b>10.3. cin &#x6E05;&#x7A7A;&#x8F93;&#x5165;&#x7F13;&#x51B2;&#x533A;</a></li><ul><li><span class="title-icon "></span><a href="#1031-&#x65B9;&#x6CD5;&#x4E00;"><b></b>10.3.1. &#x65B9;&#x6CD5;&#x4E00;</a></li><li><span class="title-icon "></span><a href="#1032-&#x65B9;&#x6CD5;&#x4E8C;"><b></b>10.3.2. &#x65B9;&#x6CD5;&#x4E8C;</a></li></ul></ul><li><span class="title-icon "></span><a href="#11----"><b></b>11.  :: / :</a></li><ul><li><span class="title-icon "></span><a href="#111-"><b></b>11.1. ::</a></li><li><span class="title-icon "></span><a href="#112-"><b></b>11.2. :</a></li><li><span class="title-icon "></span><a href="#113-&#x53C2;&#x6570;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;"><b></b>11.3. &#x53C2;&#x6570;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;</a></li></ul><li><span class="title-icon "></span><a href="#12-include"><b></b>12. include</a></li><li><span class="title-icon "></span><a href="#13-type-3"><b></b>13. type-3</a></li><ul><li><span class="title-icon "></span><a href="#131-&#x603B;&#x7ED3;type-3"><b></b>13.1. &#x603B;&#x7ED3;type-3</a></li><li><span class="title-icon "></span><a href="#132-typeid"><b></b>13.2. typeid()</a></li><li><span class="title-icon "></span><a href="#133-typename"><b></b>13.3. typename</a></li></ul><li><span class="title-icon "></span><a href="#14-privateprotectedpublic"><b></b>14. private/protected/public</a></li><ul><li><span class="title-icon "></span><a href="#141-&#x7C7B;&#x7684;&#x5185;&#x90E8;&#x5BF9;&#x5916;"><b></b>14.1. &#x7C7B;&#x7684;&#x5185;&#x90E8;&#x5BF9;&#x5916;</a></li><li><span class="title-icon "></span><a href="#142-&#x7EE7;&#x627F;"><b></b>14.2. &#x7EE7;&#x627F;</a></li><ul><li><span class="title-icon "></span><a href="#1421-&#x5B50;&#x7C7B;&#x5185;&#x90E8;&#x5BF9;&#x7236;&#x7C7B;&#x7684;&#x8BBF;&#x95EE;"><b></b>14.2.1. &#x5B50;&#x7C7B;&#x5185;&#x90E8;&#x5BF9;&#x7236;&#x7C7B;&#x7684;&#x8BBF;&#x95EE;</a></li><li><span class="title-icon "></span><a href="#1422-&#x5B50;&#x7C7B;&#x7684;&#x7236;&#x7C7B;&#x6210;&#x5458;&#x5BF9;&#x5916;"><b></b>14.2.2. &#x5B50;&#x7C7B;&#x7684;&#x7236;&#x7C7B;&#x6210;&#x5458;&#x5BF9;&#x5916;</a></li></ul></ul><li><span class="title-icon "></span><a href="#15-a--a--b&#x4E0E;a--b"><b></b>15. a = a + b&#x4E0E;a += b</a></li><li><span class="title-icon "></span><a href="#16-&#x5B8F;&#x53D8;&#x91CF;"><b></b>16. &#x5B8F;&#x53D8;&#x91CF;</a></li></ul></div><a href="#&#x5173;&#x952E;&#x5B57;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 style="font-size:60px;text-align:center;" id="&#x5173;&#x952E;&#x5B57;"><a name="&#x5173;&#x952E;&#x5B57;" class="anchor-navigation-ex-anchor" href="#&#x5173;&#x952E;&#x5B57;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5173;&#x952E;&#x5B57;</h1>

<h1 id="1-newdelete"><a name="1-newdelete" class="anchor-navigation-ex-anchor" href="#1-newdelete"><i class="fa fa-link" aria-hidden="true"></i></a>1. new/delete</h1>
<p>&#x7F16;&#x8BD1;&#x5668;&#x5206;&#x914D;&#x5185;&#x5B58;&#x7684;&#x5173;&#x952E;&#x5B57;&#xFF0C;&#x4F1A;&#x8C03;&#x7528;&#x6784;&#x9020;&#x5668;&#x4E0E;&#x6790;&#x6784;&#x5668;&#x3002;<code>malloc/free</code>&#x4E3A;&#x5E93;&#x51FD;&#x6570;&#x5B9E;&#x73B0;&#x3002;</p>
<blockquote>
<p>[!note|style:flat]
<strong><code>new/delete</code>&#x4E0E;<code>malloc/free</code>&#x5206;&#x914D;&#x5185;&#x5B58;&#x540E;&#xFF0C;&#x5747;&#x6CA1;&#x7528;&#x521D;&#x59CB;&#x5316;&#x3002;</strong></p>
</blockquote>
<pre class="language-"><code class="lang-cpp"><span class="token comment">// &#x5206;&#x914D;&#x5185;&#x5B58;&#xFF0C;&#x6CA1;&#x6709;&#x521D;&#x59CB;&#x5316;</span>
    <span class="token keyword">int</span><span class="token operator">*</span> a <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token comment">// &#x5206;&#x914D;&#x5185;&#x5B58;&#xFF0C;&#x521D;&#x59CB;&#x5316; 0 </span>
    <span class="token keyword">int</span><span class="token operator">*</span> a <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">]</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// &#x901A;&#x8FC7;&#x4F20;&#x503C;&#x521D;&#x59CB;&#x5316;</span>
    <span class="token keyword">int</span><span class="token operator">*</span> a <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">]</span><span class="token punctuation">(</span>&#x53E6;&#x4E00;&#x4E2A;<span class="token keyword">int</span><span class="token punctuation">[</span><span class="token number">10</span><span class="token punctuation">]</span>&#x7684;&#x6570;&#x7EC4;<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">delete</span><span class="token punctuation">[</span><span class="token punctuation">]</span> a<span class="token punctuation">;</span>

    <span class="token comment">// &#x7533;&#x8BF7;&#x4E00;&#x4E2A;&#x503C;&#x7684;&#x7A7A;&#x95F4;</span>
    <span class="token keyword">int</span><span class="token operator">*</span> b <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token keyword">int</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">delete</span> b<span class="token punctuation">;</span>

    <span class="token comment">// malloc &#x51FD;&#x6570;&#x7533;&#x8BF7;&#x7A7A;&#x95F4;&#xFF0C;&#x6CA1;&#x6709;&#x521D;&#x59CB;&#x5316;</span>
    <span class="token keyword">int</span><span class="token operator">*</span> a <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">int</span> <span class="token operator">*</span><span class="token punctuation">)</span> <span class="token function">malloc</span><span class="token punctuation">(</span><span class="token keyword">sizeof</span><span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span><span class="token operator">*</span><span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token function">free</span><span class="token punctuation">(</span>a<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h1 id="2-const"><a name="2-const" class="anchor-navigation-ex-anchor" href="#2-const"><i class="fa fa-link" aria-hidden="true"></i></a>2. const</h1>
<pre class="language-"><code class="lang-cpp"><span class="token comment">// &#x9650;&#x5B9A;&#x5185;&#x5BB9;</span>
<span class="token keyword">const</span> <span class="token keyword">int</span><span class="token operator">*</span>p<span class="token punctuation">;</span>
<span class="token keyword">int</span> <span class="token keyword">const</span> <span class="token operator">*</span>p<span class="token punctuation">;</span>

<span class="token comment">// &#x9650;&#x5B9A;&#x6307;&#x9488;</span>
 <span class="token keyword">int</span><span class="token operator">*</span> <span class="token keyword">const</span> p<span class="token punctuation">;</span>

<span class="token comment">// &#x90FD;&#x9650;&#x5B9A;</span>
<span class="token keyword">const</span> <span class="token keyword">int</span><span class="token operator">*</span> <span class="token keyword">const</span> p<span class="token punctuation">;</span>
</code></pre>
<ul>
<li><strong>&#x7C7B;&#x6210;&#x5458;&#x51FD;&#x6570;&#x540E;</strong>: &#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x4E0D;&#x4F1A;&#x5BF9;&#x8FD9;&#x4E2A;&#x7C7B;&#x5BF9;&#x8C61;&#x7684;&#x6570;&#x636E;&#x6210;&#x5458;&#xFF08;&#x51C6;&#x786E;&#x5730;&#x8BF4;&#x662F;&#x975E;&#x9759;&#x6001;&#x6570;&#x636E;&#x6210;&#x5458;&#xFF09;&#x4F5C;&#x4EFB;&#x4F55;&#x6539;&#x53D8;&#x3002; <font color="#f44336" style="font-weight:bold">const&#x51FD;&#x6570;&#x5185;&#xFF0C;&#x53EA;&#x80FD;&#x8C03;&#x7528;const&#x51FD;&#x6570;&#x3002;</font></li>
<li><strong>&#x7C7B;&#x6210;&#x5458;&#x51FD;&#x6570;&#x524D;</strong>: &#x8FD4;&#x56DE;&#x503C;&#x662F;&#x4E00;&#x4E2A;&#x5E38;&#x91CF;&#xFF0C;&#x4E0D;&#x80FD;&#x4FEE;&#x6539;&#xFF0C;<strong>&#x901A;&#x5E38;&#x7528;&#x6765;&#x9650;&#x5B9A;&#x5F15;&#x7528;</strong>&#x3002;</li>
<li><strong>const&#x53D8;&#x91CF;</strong>: <ul>
<li>&#x7F16;&#x8BD1;&#x5668;&#x4F1A;&#x5C06;&#x5E38;&#x91CF;&#x4F18;&#x5316;&#xFF0C;<font color="#f44336" style="font-weight:bold">&#x653E;&#x5230;&#x300C;&#x7B26;&#x53F7;&#x8868;&#x300D;&#xFF08;<code>c++</code>&#x624D;&#x6709;&#xFF09;&#xFF0C;&#x53D6;&#x503C;&#x4F1A;&#x4ECE;&#x8868;&#x4E2D;&#x76F4;&#x63A5;&#x83B7;&#x53D6;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x53BB;&#x5185;&#x5B58;</font>&#x3002;&#x901A;&#x8FC7;&#x6307;&#x9488;&#x4FEE;&#x6539;&#x503C;&#x540E;&#xFF0C;&#x503C;&#x4E0D;&#x53D8;&#x3002;</li>
<li>&#x7F16;&#x8BD1;&#x8FC7;&#x7A0B;&#x4E2D;&#x82E5;&#x53D1;&#x73B0;&#x4F7F;&#x7528;&#x5E38;&#x91CF;&#x5219;&#x76F4;&#x63A5;&#x4EE5;&#x7B26;&#x53F7;&#x8868;&#x4E2D;&#x7684;&#x503C;&#x66FF;&#x6362;</li>
<li>&#x6DFB;&#x52A0;&#x5173;&#x952E;&#x5B57;<code>volatile</code>&#xFF0C;&#x53EF;&#x4EE5;&#x9632;&#x6B62;&#x7F16;&#x8BD1;&#x5668;&#x4F18;&#x5316;&#xFF0C;&#x4ECE;&#x5185;&#x5B58;&#x53D6;&#x503C;&#x3002;&#x901A;&#x8FC7;&#x6307;&#x9488;&#x4FEE;&#x6539;&#x503C;&#x540E;&#xFF0C;&#x503C;&#x4F1A;&#x53D8;&#x3002;</li>
</ul>
</li>
<li><strong>const&#x5BF9;&#x8C61;</strong>: &#x53EA;&#x80FD;&#x8BBF;&#x95EE;<code>const</code>&#x4E0E;<code>static</code>&#x4FEE;&#x9970;&#x7684;&#x5185;&#x5BB9;&#x3002;</li>
</ul>
<h1 id="3-override"><a name="3-override" class="anchor-navigation-ex-anchor" href="#3-override"><i class="fa fa-link" aria-hidden="true"></i></a>3. override</h1>
<p>&#x2003;&#x2003;&#x914D;&#x5408; <strong>virtual</strong> &#x5173;&#x952E;&#x5B57;&#x4F7F;&#x7528;&#xFF1B;&#x4FEE;&#x9970;<strong>&#x5B50;&#x7C7B; override &#x51FD;&#x6570;</strong>&#x3002;</p>
<h1 id="4-volatile"><a name="4-volatile" class="anchor-navigation-ex-anchor" href="#4-volatile"><i class="fa fa-link" aria-hidden="true"></i></a>4. volatile</h1>
<ul>
<li><strong>&#x4F5C;&#x7528;</strong>&#xFF1A;&#x8BBF;&#x95EE;&#x5BC4;&#x5B58;&#x5668;&#x8981;&#x6BD4;&#x8BBF;&#x95EE;&#x5185;&#x5B58;&#x8981;&#x5757;&#xFF0C;&#x56E0;&#x6B64;<code>CPU</code>&#x4F1A;&#x4F18;&#x5148;&#x8BBF;&#x95EE;&#x8BE5;&#x6570;&#x636E;&#x5728;&#x5BC4;&#x5B58;&#x5668;&#x4E2D;&#x7684;&#x5B58;&#x50A8;&#x7ED3;&#x679C;&#xFF0C;&#x4F46;&#x662F;&#x5185;&#x5B58;&#x4E2D;&#x7684;&#x6570;&#x636E;&#x53EF;&#x80FD;&#x5DF2;&#x7ECF;&#x53D1;&#x751F;&#x4E86;&#x6539;&#x53D8;&#xFF0C;&#x800C;&#x5BC4;&#x5B58;&#x5668;&#x4E2D;&#x8FD8;&#x4FDD;&#x7559;&#x7740;&#x539F;&#x6765;&#x7684;&#x7ED3;&#x679C;&#x3002;&#x4E3A;&#x4E86;&#x907F;&#x514D;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#x7684;&#x53D1;&#x751F;&#x5C06;&#x8BE5;&#x53D8;&#x91CF;&#x58F0;&#x660E;&#x4E3A;<code>volatile</code>&#xFF0C;<strong>&#x544A;&#x8BC9;<code>CPU</code>&#x6BCF;&#x6B21;&#x90FD;&#x4ECE;&#x5185;&#x5B58;&#x53BB;&#x8BFB;&#x53D6;&#x6570;&#x636E;&#x3002;</strong></li>
<li><strong>&#x6CA1;&#x6709;&#x7EBF;&#x7A0B;&#x540C;&#x6B65;&#x7684;&#x8BED;&#x4E49;</strong></li>
</ul>
<h1 id="5-static"><a name="5-static" class="anchor-navigation-ex-anchor" href="#5-static"><i class="fa fa-link" aria-hidden="true"></i></a>5. static</h1>
<ul>
<li><strong>&#x51FD;&#x6570;&#x4F53;&#x5185;</strong>&#xFF1A; &#x4FEE;&#x9970;&#x7684;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x4F5C;&#x7528;&#x8303;&#x56F4;&#x4E3A;&#x8BE5;&#x51FD;&#x6570;&#x4F53;&#xFF0C;<strong>&#x5728;&#x5185;&#x5B58;&#x53EA;&#x88AB;&#x5206;&#x914D;&#x4E00;&#x6B21;&#xFF0C;&#x4E0B;&#x6B21;&#x8C03;&#x7528;&#x7684;&#x65F6;&#x5019;&#x7EF4;&#x6301;&#x4E86;&#x4E0A;&#x6B21;&#x7684;&#x503C;</strong>&#x3002;</li>
<li><font color="#f44336" style="font-weight:bold">&#x6E90;&#x6587;&#x4EF6;&#x5168;&#x5C40;</font>&#xFF1A;&#x4FEE;&#x9970;&#x7684;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x6216;&#x51FD;&#x6570;&#xFF0C;&#x8303;&#x56F4;&#x9650;&#x5236;&#x5728;&#x58F0;&#x660E;&#x5B83;&#x7684;&#x6A21;&#x5757;&#x5185;&#xFF0C;<strong>&#x4E0D;&#x80FD;&#x88AB;extern&#x627E;&#x5230;</strong>&#x3002;</li>
<li><strong>&#x7C7B;&#x4E2D;&#x4FEE;&#x9970;&#x6210;&#x5458;&#x53D8;&#x91CF;</strong>: &#x8868;&#x793A;&#x8BE5;&#x53D8;&#x91CF;&#x5C5E;&#x4E8E;&#x6574;&#x4E2A;&#x7C7B;&#x6240;&#x6709;&#xFF0C;&#x5BF9;&#x7C7B;&#x7684;&#x6240;&#x6709;&#x5BF9;&#x8C61;&#x53EA;&#x6709;&#x4E00;&#x4EFD;&#x62F7;&#x8D1D;&#x3002;<ul>
<li><font color="#f44336">&#x5728;&#x7C7B;&#x91CC;&#x58F0;&#x660E;&#xFF0C;&#x5230;&#x7C7B;&#x5916;&#x5B9E;&#x73B0;</font></li>
<li><strong>&#x7C7B;&#x5916;&#x5168;&#x5C40;&#x5904;&#x5B9E;&#x73B0;</strong>&#xFF0C;&#x4E0D;&#x7528;<code>static</code>&#x4FEE;&#x9970;</li>
<li><strong>&#x5168;&#x5BF9;&#x8C61;&#x5171;&#x4EAB;</strong></li>
</ul>
</li>
<li><strong>&#x7C7B;&#x4E2D;&#x4FEE;&#x9970;&#x6210;&#x5458;&#x51FD;&#x6570;</strong>: &#x8868;&#x793A;&#x8BE5;&#x51FD;&#x6570;&#x5C5E;&#x4E8E;&#x6574;&#x4E2A;&#x7C7B;&#x6240;&#x6709;&#xFF0C;<strong>&#x4E0D;&#x63A5;&#x53D7;this&#x6307;&#x9488;</strong>&#xFF0C;&#x53EA;&#x80FD;&#x8BBF;&#x95EE;&#x7C7B;&#x4E2D;&#x7684;<code>static</code>&#x6210;&#x5458;&#x53D8;&#x91CF;&#x3002;<ul>
<li><strong>&#x7C7B;&#x7684;&#x91CC;/&#x5916;&#x90FD;&#x80FD;&#x5B9E;&#x73B0;</strong>&#xFF0C;&#x7C7B;&#x5916;&#x5B9E;&#x73B0;&#x7701;&#x7565;<code>static</code></li>
</ul>
</li>
</ul>
<h1 id="6--extern-c"><a name="6--extern-c" class="anchor-navigation-ex-anchor" href="#6--extern-c"><i class="fa fa-link" aria-hidden="true"></i></a>6.  extern &quot;C&quot;</h1>
<ul>
<li>&#x4F1A;&#x6307;&#x793A;&#x7F16;&#x8BD1;&#x5668;&#x8FD9;&#x90E8;&#x5206;&#x4EE3;&#x7801;&#x6309;<code>C</code>&#x8BED;&#x8A00;&#x7684;&#x8FDB;&#x884C;&#x7F16;&#x8BD1;&#xFF0C;&#x800C;&#x4E0D;&#x662F;<code>C++</code>&#x7684;;&#x80FD;&#x591F;&#x6B63;&#x786E;&#x5B9E;&#x73B0;<code>C++</code>&#x4EE3;&#x7801;&#x8C03;&#x7528;&#x5176;&#x4ED6;<code>C</code>&#x8BED;&#x8A00;&#x4EE3;&#x7801;&#x3002;</li>
</ul>
<h1 id="7--extern"><a name="7--extern" class="anchor-navigation-ex-anchor" href="#7--extern"><i class="fa fa-link" aria-hidden="true"></i></a>7.  extern</h1>
<ul>
<li><strong>&#x95EE;&#x9898;</strong>&#xFF1A;<code>include</code>&#x53EF;&#x4EE5;&#x4F7F;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x80FD;&#x591F;&#x5305;&#x542B;&#x5176;&#x4ED6;&#x6587;&#x4EF6;&#xFF0C;&#x80FD;&#x591F;&#x4F7F;&#x7528;&#x91CC;&#x9762;&#x7684;&#x300C;&#x53D8;&#x91CF;&#x6216;&#x8005;&#x51FD;&#x6570;&#x300D;&#x3002;&#x4F46;&#x662F;&#x8FD9;&#x6837;&#x505A;&#x7684;&#x7ED3;&#x679C;&#x5C31;&#x662F;&#xFF0C;&#x88AB;&#x5305;&#x542B;&#x7684;&#x6587;&#x4EF6;&#x4E2D;&#x7684;&#x6240;&#x6709;&#x7684;&#x300C;&#x53D8;&#x91CF;&#x548C;&#x51FD;&#x6570;&#x300D;&#x90FD;&#x53EF;&#x4EE5;&#x88AB;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#x4F7F;&#x7528;&#xFF0C;&#x8FD9;&#x6837;&#x5C31;&#x53D8;&#x5F97;&#x4E0D;&#x5B89;&#x5168;&#x3002;</li>
<li><strong>&#x9650;&#x5236;&#x67D0;&#x4E9B;&#x300C;&#x53D8;&#x91CF;&#x548C;&#x51FD;&#x6570;&#x300D;&#x4E0D;&#x80FD;&#x88AB;&#x5176;&#x4ED6;&#x6587;&#x4EF6;&#x4F7F;&#x7528;&#xFF1A;</strong><ul>
<li><strong><code>.h</code>&#x6587;&#x4EF6;&#xFF1A;&#x80FD;&#x88AB;&#x5176;&#x4ED6;&#x6587;&#x4EF6;&#x4F7F;&#x7528;&#x7684;&#x53D8;&#x91CF;&#x6216;&#x8005;&#x51FD;&#x6570;&#xFF0C;&#x5229;&#x7528;<code>extern</code>&#x8FDB;&#x884C;&#x4FEE;&#x9970;&#x9650;&#x5B9A;&#x3002;&#x4E0D;&#x60F3;&#x88AB;&#x5176;&#x4ED6;&#x6587;&#x4EF6;&#x4F7F;&#x7528;&#x7684;&#xFF0C;&#x5C31;&#x522B;&#x5728;<code>.h</code>&#x91CC;&#x5199;&#x3002;</strong></li>
<li><strong><code>.cpp</code>&#x6587;&#x4EF6;&#xFF1A;&#x4E0D;&#x60F3;&#x88AB;&#x5176;&#x4ED6;&#x6587;&#x4EF6;&#x6240;&#x4F7F;&#x7528;&#x7684;&#x53D8;&#x91CF;&#x6216;&#x8005;&#x51FD;&#x6570;&#xFF0C;&#x5229;&#x7528;<code>static</code>&#x8FDB;&#x884C;&#x4FEE;&#x9970;&#x3002;</strong></li>
</ul>
</li>
<li><font color="#f44336">&#x6E90;&#x6587;&#x4EF6;</font>&#x4E2D;&#x7684;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x4E0E;&#x51FD;&#x6570;&#x5B9A;&#x4E49;&#xFF0C;&#x9ED8;&#x8BA4;&#x90FD;&#x80FD;&#x88AB;<code>extern</code>&#x627E;&#x5230;&#x3002;</li>
</ul>
<blockquote>
<p>[!tip]
<strong>&#x9650;&#x5236;&#x67D0;&#x4E9B;&#x300C;&#x7ED3;&#x6784;&#x4F53;&#x548C;&#x7C7B;&#x300D;:</strong></p>
<ul>
<li>&#x60F3;&#x7ED9;&#x522B;&#x4EBA;&#x7528;&#xFF0C;&#x5C31;&#x628A;&#x58F0;&#x660E;&#x5199;<code>.h</code>&#x91CC;&#xFF1B;&#x4E0D;&#x60F3;&#x7ED9;&#x522B;&#x4EBA;&#x7528;&#xFF0C;&#x5C31;&#x628A;&#x58F0;&#x660E;&#x5199;<code>.cpp</code>&#x91CC;&#x3002;</li>
<li><strong>&#x7ED3;&#x6784;&#x4F53;&#x548C;&#x7C7B;&#x7684;&#x300C;&#x5B9A;&#x4E49;&#x300D;&#xFF0C;&#x4E0D;&#x80FD;&#x4F7F;&#x7528;<code>extern</code>&#x4E0E;<code>static</code>&#x8FDB;&#x884C;&#x4FEE;&#x9970;&#x3002;</strong></li>
</ul>
</blockquote>
<h1 id="8--friend"><a name="8--friend" class="anchor-navigation-ex-anchor" href="#8--friend"><i class="fa fa-link" aria-hidden="true"></i></a>8.  friend</h1>
<p><strong>&#x53EF;&#x4EE5;&#x8BA9;&#x5916;&#x90E8;&#x51FD;&#x6570;&#x6216;&#x8005;&#x5916;&#x90E8;&#x7C7B;&#xFF0C;&#x8BBF;&#x95EE;&#x79C1;&#x6709;&#x7C7B;&#x7684;&#x79C1;&#x6709;&#x5C5E;&#x6027;&#x4E0E;&#x51FD;&#x6570;&#x3002;</strong></p>
<ul>
<li><strong>&#x53CB;&#x5143;&#x51FD;&#x6570;</strong><ul>
<li>&#x5B9A;&#x4E49;&#x5728;&#x7C7B;&#x5916;&#x7684;&#x666E;&#x901A;&#x51FD;&#x6570;</li>
<li>&#x9700;&#x8981;&#x5728;&#x7C7B;&#x4E2D;&#x58F0;&#x660E;</li>
</ul>
</li>
<li><strong>&#x53CB;&#x5143;&#x7C7B;</strong>: &#x53CB;&#x5143;&#x7C7B;&#x7684;&#x6240;&#x6709;&#x6210;&#x5458;&#x51FD;&#x6570;&#x90FD;&#x662F;&#x53E6;&#x4E00;&#x4E2A;&#x7C7B;&#x7684;&#x53CB;&#x5143;&#x51FD;&#x6570;&#xFF0C;&#x90FD;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x53E6;&#x4E00;&#x4E2A;&#x7C7B;&#x4E2D;&#x7684;&#x9690;&#x85CF;&#x4FE1;&#x606F;&#xFF08;&#x5305;&#x62EC;&#x79C1;&#x6709;&#x6210;&#x5458;&#x548C;&#x4FDD;&#x62A4;&#x6210;&#x5458;&#xFF09;&#x3002;<ul>
<li>&#x4E0D;&#x80FD;&#x88AB;&#x7EE7;&#x627F;</li>
<li>&#x4E24;&#x4E2A;&#x7C7B;&#x7684;&#x5173;&#x7CFB;&#x662F;&#x5355;&#x5411;&#x7684;</li>
<li>&#x4E0D;&#x53EF;&#x4F20;&#x9012;</li>
</ul>
</li>
</ul>
<h1 id="9--&#x50A8;&#x5B58;&#x7C7B;&#x578B;&#x7B26;"><a name="9--&#x50A8;&#x5B58;&#x7C7B;&#x578B;&#x7B26;" class="anchor-navigation-ex-anchor" href="#9--&#x50A8;&#x5B58;&#x7C7B;&#x578B;&#x7B26;"><i class="fa fa-link" aria-hidden="true"></i></a>9.  &#x50A8;&#x5B58;&#x7C7B;&#x578B;&#x7B26;</h1>
<ul>
<li><strong>auto</strong>&#xFF1A;&#x6240;&#x6709;<strong>&#x5C40;&#x90E8;&#x53D8;&#x91CF;</strong>&#x9ED8;&#x8BA4;&#x7684;&#x5B58;&#x50A8;&#x7C7B;&#xFF0C; <strong>&#x5BF9;&#x4E8E;C&#xFF0C; &#x5757;&#x8BED;&#x53E5;&#x4E2D;&#x4E5F;&#x53EF;&#x5B9A;&#x4E49;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#xFF0C;&#x5F62;&#x53C2;&#x4E5F;&#x662F;&#x3002;</strong></li>
<li><strong>register</strong>: &#x5B58;&#x50A8;&#x5728;&#x5BC4;&#x5B58;&#x5668;&#x4E2D;&#xFF08;&#x53EA;&#x662F;&#x5EFA;&#x8BAE;&#xFF0C;&#x5177;&#x4F53;&#x5B9E;&#x73B0;&#x770B;&#x7F16;&#x8BD1;&#x5668;&#xFF09;&#x3002;</li>
<li><strong>static</strong>&#xFF1A;&#x5C40;&#x90E8;&#x4FEE;&#x9970;&#x53D8;&#x91CF;&#x540E;&#x6539;&#x53D8;&#x4E86;&#x751F;&#x5B58;&#x671F;;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x4FEE;&#x9970;&#x540E;&#x6539;&#x53D8;&#x4E86;&#x4F5C;&#x7528;&#x57DF;</li>
<li><strong>extern</strong>&#xFF1A;&#x5F15;&#x5165;&#x5176;&#x4ED6;<code>.C</code>&#x6587;&#x4EF6;&#x4E2D;&#x5DF2;&#x5B9A;&#x4E49;&#x7684;&#x975E;<code>static</code>&#x5168;&#x5C40;&#x53D8;&#x91CF;;&#x53EF;&#x4EE5;&#x5728;&#x51FD;&#x6570;&#x7684;&#x5185;&#x5916;&#x58F0;&#x660E;&#x53D8;&#x91CF;&#x6216;&#x8005;&#x51FD;&#x6570;&#x3002;</li>
<li><strong>mutable</strong>&#xFF1A;&#x4EC5;&#x9002;&#x7528;&#x4E8E;&#x7C7B;&#x7684;&#x5BF9;&#x8C61;&#x6210;&#x5458;&#x53D8;&#x91CF;&#xFF0C;&#x5B83;&#x5141;&#x8BB8;<code>const</code>&#x51FD;&#x6570;&#x80FD;&#x5BF9;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x8FDB;&#x884C;&#x4FEE;&#x6539;</li>
</ul>
<h1 id="10--cin"><a name="10--cin" class="anchor-navigation-ex-anchor" href="#10--cin"><i class="fa fa-link" aria-hidden="true"></i></a>10.  cin</h1>
<h2 id="101-&#x7B80;&#x4ECB;"><a name="101-&#x7B80;&#x4ECB;" class="anchor-navigation-ex-anchor" href="#101-&#x7B80;&#x4ECB;"><i class="fa fa-link" aria-hidden="true"></i></a>10.1. &#x7B80;&#x4ECB;</h2>
<ul>
<li>&#x9047;&#x5230;  <code>\n</code>  &#x624D;&#x4F1A;&#x5C06;&#x5199;&#x5165;&#x5185;&#x5BB9;&#x52A0;&#x8F7D;&#x5230;&#x7F13;&#x51B2;&#x533A;</li>
<li><code>\n</code> &#x4E5F;&#x7B97;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#xFF0C;&#x4F1A;&#x88AB;&#x52A0;&#x8F7D;&#x5230;&#x7F13;&#x51B2;&#x533A;</li>
<li>&#x7F13;&#x51B2;&#x533A;&#x4E3A;&#x7A7A;&#x65F6;&#xFF0C;<code>cin</code> &#x963B;&#x585E;&#x7B49;&#x5F85;&#x6570;&#x636E;;&#x4E00;&#x65E6;&#x7F13;&#x51B2;&#x533A;&#x4E2D;&#x6709;&#x6570;&#x636E;&#xFF0C;&#x5C31;&#x89E6;&#x53D1; <code>cin</code> &#x53BB;&#x8BFB;&#x53D6;&#x6570;&#x636E;&#x3002;</li>
<li><strong>&#x9047;&#x5230;<code>EOF</code>&#x4F1A;&#x7ED3;&#x675F;&#x3002;</strong><blockquote>
<p>[!tip|style:flat] <strong>&#x53EF;&#x7528;&#x6765;&#x5FAA;&#x73AF;&#x8BFB;&#x53D6;&#x503C;</strong></p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">while</span><span class="token punctuation">(</span>cin <span class="token operator">&gt;&gt;</span> value<span class="token punctuation">)</span><span class="token punctuation">{</span><span class="token punctuation">}</span>
</code></pre>
</blockquote>
</li>
</ul>
<h2 id="102-&#x7528;&#x6CD5;"><a name="102-&#x7528;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#102-&#x7528;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>10.2. &#x7528;&#x6CD5;</h2>
<h3 id="1021-cin-"><a name="1021-cin-" class="anchor-navigation-ex-anchor" href="#1021-cin-"><i class="fa fa-link" aria-hidden="true"></i></a>10.2.1. <code>cin &gt;&gt;</code></h3>
<ul>
<li><p>&#x8FDE;&#x7EED;&#x4ECE;&#x952E;&#x76D8;&#x8BFB;&#x53D6;&#x60F3;&#x8981;&#x7684;&#x6570;&#x636E;&#xFF0C;<font color="#f44336">&#x4EE5;&#x7A7A;&#x683C;&#x3001;tab &#x3001;&#x6362;&#x884C;&#x4E3A;&#x5206;&#x9694;&#x7B26;</font>&#x3002;</p>
<pre class="language-"><code class="lang-cpp">  <span class="token keyword">char</span> a<span class="token punctuation">;</span>
        <span class="token keyword">int</span> b<span class="token punctuation">;</span>
        <span class="token keyword">float</span> c<span class="token punctuation">;</span>
        string 
        cin<span class="token operator">&gt;&gt;</span>a<span class="token operator">&gt;&gt;</span>b<span class="token operator">&gt;&gt;</span>c<span class="token punctuation">;</span>
</code></pre>
<ul>
<li>&#x5F53; <code>cin &gt;&gt;</code>  &#x4ECE;&#x7F13;&#x51B2;&#x533A;&#x4E2D;&#x8BFB;&#x53D6;&#x6570;&#x636E;&#x65F6;&#xFF0C;<strong>&#x82E5;&#x7F13;&#x51B2;&#x533A;&#x4E2D;&#x7B2C;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x662F;&#x7A7A;&#x683C;&#x3001;tab&#x6216;&#x6362;&#x884C;&#x8FD9;&#x4E9B;&#x5206;&#x9694;&#x7B26;&#x65F6;&#xFF0C;cin&gt;&gt; &#x4F1A;&#x5C06;&#x5176;<font color="#f44336">&#x5FFD;&#x7565;&#x5E76;&#x6E05;&#x9664;</font>&#xFF0C;&#x7EE7;&#x7EED;&#x8BFB;&#x53D6;&#x4E0B;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;</strong>; &#x82E5;&#x7F13;&#x51B2;&#x533A;&#x4E3A;&#x7A7A;&#xFF0C;&#x5219;&#x7EE7;&#x7EED;&#x7B49;&#x5F85;&#x3002;<font color="#f44336">&#x4F46;&#x662F;&#x5982;&#x679C;&#x8BFB;&#x53D6;&#x6210;&#x529F;&#xFF0C;&#x5B57;&#x7B26;&#x540E;&#x9762;&#x7684; <strong>&#x7A7A;&#x767D;&#x7B26;&#x53F7;</strong> &#x662F;&#x6B8B;&#x7559;&#x5728;&#x7F13;&#x51B2;&#x533A;&#x7684;&#xFF0C;<code>cin&gt;&gt;</code> &#x4E0D;&#x505A;&#x5904;&#x7406;&#x3002;</font></li>
<li>&#x4E0D;&#x60F3;&#x7565;&#x8FC7;&#x7A7A;&#x767D;&#x5B57;&#x7B26;&#xFF0C;&#x90A3;&#x5C31;&#x4F7F;&#x7528; noskipws &#x6D41;&#x63A7;&#x5236;&#x3002;</li>
<li><p><code>cin &gt;&gt;</code>&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x4E3A;  <code>cin</code> ;&#x5F53;&#x8F93;&#x5165; <code>EOF</code> &#xFF08;windows:ctrl+z&#xFF0C; Linux:ctrl+d&#xFF09;&#x65F6;&#xFF0C; <code>cin &gt;&gt;</code> &#x4F1A;&#x8FD4;&#x56DE;<code>0</code>&#x3002;</p>
<pre class="language-"><code class="lang-cpp">  <span class="token keyword">int</span> a<span class="token punctuation">;</span>
  <span class="token comment">// &#x5F53;&#x8F93;&#x5165; EOF &#x65F6;&#xFF0C;&#x53EF;&#x4EE5;&#x7EC8;&#x6B62;&#x5FAA;&#x73AF;</span>
  <span class="token keyword">while</span>&#xFF08;cin <span class="token operator">&gt;&gt;</span> a&#xFF09;<span class="token punctuation">{</span>

  <span class="token punctuation">}</span>
</code></pre>
</li>
</ul>
</li>
</ul>
<h3 id="1022--cinget"><a name="1022--cinget" class="anchor-navigation-ex-anchor" href="#1022--cinget"><i class="fa fa-link" aria-hidden="true"></i></a>10.2.2.  <code>cin.get()</code></h3>
<blockquote>
<p>[!note|style:flat]</p>
<font color="#f44336" style="font-weight:bold">&#x7F13;&#x51B2;&#x533A;&#x6CA1;&#x6709;&#x4E1C;&#x897F;&#x65F6;&#xFF0C;&#x4F1A;&#x5835;&#x585E;&#x7B49;&#x5F85;&#x3002;</font>

</blockquote>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">int</span> <span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
istream<span class="token operator">&amp;</span> <span class="token function">get</span><span class="token punctuation">(</span><span class="token keyword">char</span><span class="token operator">&amp;</span> var<span class="token punctuation">)</span><span class="token punctuation">;</span>
istream<span class="token operator">&amp;</span> <span class="token function">get</span><span class="token punctuation">(</span> <span class="token keyword">char</span><span class="token operator">*</span> s<span class="token punctuation">,</span> streamsize n <span class="token punctuation">)</span><span class="token punctuation">;</span>
istream<span class="token operator">&amp;</span> <span class="token function">get</span><span class="token punctuation">(</span> <span class="token keyword">char</span><span class="token operator">*</span> s<span class="token punctuation">,</span>  streamsize  n<span class="token punctuation">,</span> <span class="token keyword">char</span> delim<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<p><strong>&#x8BFB;&#x53D6;&#x5B57;&#x7B26;</strong> :</p>
<pre class="language-"><code class="lang-cpp"><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span> <span class="token string">&lt;iostream&gt;</span></span>
<span class="token keyword">using</span> <span class="token keyword">namespace</span> std<span class="token punctuation">;</span>

<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">char</span> a<span class="token punctuation">;</span>
    <span class="token keyword">char</span> b<span class="token punctuation">;</span>
    a<span class="token operator">=</span>cin<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    cin<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>b<span class="token punctuation">)</span><span class="token punctuation">;</span>
    cout <span class="token operator">&lt;&lt;</span> a <span class="token operator">&lt;&lt;</span> b <span class="token operator">&lt;&lt;</span>endl<span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
<ul>
<li><font color="#f44336" style="font-weight:bold">&#x4ECE;&#x8F93;&#x5165;&#x7F13;&#x51B2;&#x533A;&#x8BFB;&#x53D6;&#x5355;&#x4E2A;&#x5B57;&#x7B26;&#x65F6;&#x4E0D;&#x5FFD;&#x7565;&#x5206;&#x9694;&#x7B26;&#xFF0C;&#x76F4;&#x63A5;&#x5C06;&#x5176;&#x8BFB;&#x53D6;&#x3002;</font>

</li>
</ul>
<p><strong>&#x8BFB;&#x53D6;&#x884C;</strong></p>
<pre class="language-"><code class="lang-cpp">istream<span class="token operator">&amp;</span> <span class="token function">get</span><span class="token punctuation">(</span><span class="token keyword">char</span><span class="token operator">*</span> s<span class="token punctuation">,</span> streamsize n<span class="token punctuation">)</span>
istream<span class="token operator">&amp;</span> <span class="token function">get</span><span class="token punctuation">(</span><span class="token keyword">char</span><span class="token operator">*</span> s<span class="token punctuation">,</span> size_t n<span class="token punctuation">,</span> <span class="token keyword">char</span> delim<span class="token punctuation">)</span>
</code></pre>
<ul>
<li><code>s</code> &#xFF0C;&#x63A5;&#x6536;&#x5B57;&#x7B26;&#x4E32;&#x7528;&#x7684;&#x6570;&#x7EC4;</li>
<li><code>n</code> &#xFF0C;&#x8BFB;&#x53D6;&#x4E2A;&#x6570;&#x3002;<font color="#f44336">&#x5B9E;&#x9645;&#x8BFB;&#x53D6;&#x4E2A;&#x6570;&#x4E3A;  <code>n - 1</code> &#xFF0C;&#x7559;&#x4E86;&#x4E00;&#x4E2A;&#x7ED9;  <code>\0</code> </font></li>
<li><code>delim</code> &#xFF0C;&#x6307;&#x5B9A;&#x7EC8;&#x6B62;&#x7B26;</li>
<li><strong>&#x6362;&#x884C;&#x7B26;(&#x7ED3;&#x675F;&#x7B26;)&#x4F1A;&#x88AB;&#x7559;&#x5728;&#x7F13;&#x51B2;&#x533A;</strong>&#xFF0C;<span style="color:red;font-weight:bold"> &#x4F46;&#x672B;&#x5C3E;&#x5176;&#x4F59;&#x7A7A;&#x767D;&#x7B26;&#x4F1A;&#x88AB;&#x8BFB;&#x53D6;&#x3002; </span></li>
</ul>
<h3 id="1023-cingetline&#xFF08;&#xFF09;--&#x8BFB;&#x53D6;&#x884C;"><a name="1023-cingetline&#xFF08;&#xFF09;--&#x8BFB;&#x53D6;&#x884C;" class="anchor-navigation-ex-anchor" href="#1023-cingetline&#xFF08;&#xFF09;--&#x8BFB;&#x53D6;&#x884C;"><i class="fa fa-link" aria-hidden="true"></i></a>10.2.3. <code>cin.getline&#xFF08;&#xFF09;</code>  <strong>&#x8BFB;&#x53D6;&#x884C;</strong></h3>
<pre class="language-"><code class="lang-cpp">istream<span class="token operator">&amp;</span> <span class="token function">getline</span><span class="token punctuation">(</span><span class="token keyword">char</span><span class="token operator">*</span> s<span class="token punctuation">,</span> streamsize count<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">//&#x9ED8;&#x8BA4;&#x4EE5;&#x6362;&#x884C;&#x7B26;&#x7ED3;&#x675F;</span>
istream<span class="token operator">&amp;</span> <span class="token function">getline</span><span class="token punctuation">(</span><span class="token keyword">char</span><span class="token operator">*</span> s<span class="token punctuation">,</span> streamsize count<span class="token punctuation">,</span> <span class="token keyword">char</span> delim<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<ul>
<li><strong>&#x6362;&#x884C;&#x7B26;(&#x7ED3;&#x675F;&#x7B26;)&#x4F1A;&#x88AB;&#x6E05;&#x7406;&#x6389;</strong>&#xFF0C;<span style="color:red;font-weight:bold"> &#x4F46;&#x672B;&#x5C3E;&#x5176;&#x4F59;&#x7A7A;&#x767D;&#x7B26;&#x4F1A;&#x88AB;&#x8BFB;&#x53D6;&#x3002; </span></li>
<li><code>getline(cin,string,&quot;&#x7ED3;&#x675F;&#x7B26;&quot;)</code> &#x529F;&#x80FD;&#x66F4;&#x5F3A;&#x3002;<font color="#f44336">&#x4F20;&#x5165;&#x7684;&#x662F;  <code>cin</code>  &#xFF0C;&#x4E0D;&#x662F;  <code>stdin</code>  </font></li>
</ul>
<h2 id="103-cin-&#x6E05;&#x7A7A;&#x8F93;&#x5165;&#x7F13;&#x51B2;&#x533A;"><a name="103-cin-&#x6E05;&#x7A7A;&#x8F93;&#x5165;&#x7F13;&#x51B2;&#x533A;" class="anchor-navigation-ex-anchor" href="#103-cin-&#x6E05;&#x7A7A;&#x8F93;&#x5165;&#x7F13;&#x51B2;&#x533A;"><i class="fa fa-link" aria-hidden="true"></i></a>10.3. cin &#x6E05;&#x7A7A;&#x8F93;&#x5165;&#x7F13;&#x51B2;&#x533A;</h2>
<h3 id="1031-&#x65B9;&#x6CD5;&#x4E00;"><a name="1031-&#x65B9;&#x6CD5;&#x4E00;" class="anchor-navigation-ex-anchor" href="#1031-&#x65B9;&#x6CD5;&#x4E00;"><i class="fa fa-link" aria-hidden="true"></i></a>10.3.1. &#x65B9;&#x6CD5;&#x4E00;</h3>
<pre class="language-"><code class="lang-cpp">istream <span class="token operator">&amp;</span><span class="token function">ignore</span><span class="token punctuation">(</span>streamsize num<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token keyword">int</span> delim<span class="token operator">=</span><span class="token constant">EOF</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<ul>
<li><strong>&#x8DF3;&#x8FC7;&#x8F93;&#x5165;&#x6D41;&#x4E2D;  <code>num</code>  &#x4E2A;&#x5B57;&#x7B26;&#xFF0C;&#x6216;&#x9047;&#x5230;&#x7EC8;&#x6B62;&#x7B26;  <code>delim</code> &#x7ED3;&#x675F;&#xFF08;&#x5305;&#x62EC;&#x7EC8;&#x6B62;&#x7B26;&#xFF09;&#x3002;</strong></li>
<li><code>ignore()</code> <strong> &#x4F1A;&#x963B;&#x585E;&#x7B49;&#x5F85;&#xFF0C;&#x6700;&#x597D;&#x522B;&#x7528;  <code>EOF</code> &#x505A;&#x7EC8;&#x6B62;&#x7B26;</strong>&#x3002;</li>
<li><code>num</code> : &#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x4E00;&#x4E2A;&#x5F88;&#x5927;&#x7684;&#x6570;<pre class="language-"><code>  #include <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>limits</span><span class="token punctuation">&gt;</span></span>
   numeric_limits<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span><span class="token namespace">std:</span>:streamsize</span><span class="token punctuation">&gt;</span></span>::max();
</code></pre></li>
</ul>
<h3 id="1032-&#x65B9;&#x6CD5;&#x4E8C;"><a name="1032-&#x65B9;&#x6CD5;&#x4E8C;" class="anchor-navigation-ex-anchor" href="#1032-&#x65B9;&#x6CD5;&#x4E8C;"><i class="fa fa-link" aria-hidden="true"></i></a>10.3.2. &#x65B9;&#x6CD5;&#x4E8C;</h3>
<pre class="language-"><code class="lang-cpp"><span class="token function">fflush</span><span class="token punctuation">(</span><span class="token constant">stdin</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre>
<h1 id="11----"><a name="11----" class="anchor-navigation-ex-anchor" href="#11----"><i class="fa fa-link" aria-hidden="true"></i></a>11.  <code>:: / :</code></h1>
<h2 id="111-"><a name="111-" class="anchor-navigation-ex-anchor" href="#111-"><i class="fa fa-link" aria-hidden="true"></i></a>11.1. <code>::</code></h2>
<ul>
<li><p>&#x5F53;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x4E0E;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x91CD;&#x540D;&#xFF0C;&#x53EF;&#x4EE5;&#x4FEE;&#x9970;&#x53D8;&#x91CF;&#xFF0C;&#x8BBF;&#x95EE;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x3002;<font color="#f44336">&#x4EC5;c++&#x652F;&#x6301;</font></p>
<pre class="language-"><code class="lang-cpp">  <span class="token keyword">int</span> x<span class="token punctuation">;</span>  <span class="token comment">// Global x </span>

    <span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span> 
    <span class="token punctuation">{</span> 
    <span class="token keyword">int</span> x <span class="token operator">=</span> <span class="token number">10</span><span class="token punctuation">;</span> <span class="token comment">// Local x </span>
    cout <span class="token operator">&lt;&lt;</span> <span class="token string">&quot;Value of global x is &quot;</span> <span class="token operator">&lt;&lt;</span> <span class="token double-colon punctuation">::</span>x<span class="token punctuation">;</span> 
    cout <span class="token operator">&lt;&lt;</span> <span class="token string">&quot;\nValue of local x is &quot;</span> <span class="token operator">&lt;&lt;</span> x<span class="token punctuation">;</span>  
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span> 
    <span class="token punctuation">}</span>
</code></pre>
</li>
<li>&#x5728;&#x7C7B;&#x4E4B;&#x5916;&#x5B9A;&#x4E49;&#x51FD;&#x6570;</li>
<li><p>&#x8BBF;&#x95EE;&#x7C7B;&#x7684;&#x5168;&#x5C40;&#x53D8;&#x91CF;</p>
<pre class="language-"><code class="lang-cpp">  <span class="token keyword">class</span> <span class="token class-name">Test</span> 
    <span class="token punctuation">{</span>   
    <span class="token keyword">public</span><span class="token operator">:</span> 
        <span class="token keyword">static</span> <span class="token keyword">int</span> x<span class="token punctuation">;</span> 
    <span class="token punctuation">}</span><span class="token punctuation">;</span>

    <span class="token keyword">int</span> Test<span class="token double-colon punctuation">::</span>x <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>

    <span class="token keyword">void</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        Test<span class="token double-colon punctuation">::</span>x<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
</code></pre>
</li>
<li>&#x5982;&#x679C;&#x6709;&#x591A;&#x4E2A;&#x7EE7;&#x627F;&#xFF0C;&#x7236;&#x7C7B;&#x53D8;&#x91CF;&#x540D;&#x91CD;&#x540D;&#xFF0C;&#x5B50;&#x7C7B;&#x53EF;&#x4EE5;&#x505A;&#x533A;&#x5206;&#x3002;</li>
<li>&#x4E24;&#x4E2A;&#x547D;&#x540D;&#x7A7A;&#x95F4;&#x91CD;&#x547D;&#x540D;</li>
<li><p>&#x8BBF;&#x95EE;&#x5185;&#x90E8;&#x7C7B;</p>
<pre class="language-"><code class="lang-cpp">  <span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">include</span><span class="token string">&lt;iostream&gt;</span> </span>
    <span class="token keyword">using</span> <span class="token keyword">namespace</span> std<span class="token punctuation">;</span> 

    <span class="token keyword">class</span> <span class="token class-name">outside</span> 
    <span class="token punctuation">{</span> 
    <span class="token keyword">public</span><span class="token operator">:</span> 
        <span class="token keyword">int</span> x<span class="token punctuation">;</span> 
        <span class="token keyword">class</span> <span class="token class-name">inside</span> 
        <span class="token punctuation">{</span> 
        <span class="token keyword">public</span><span class="token operator">:</span> 
                <span class="token keyword">int</span> x<span class="token punctuation">;</span> 
                <span class="token keyword">static</span> <span class="token keyword">int</span> y<span class="token punctuation">;</span>  
                <span class="token keyword">int</span> <span class="token function">foo</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> 

        <span class="token punctuation">}</span><span class="token punctuation">;</span> 
    <span class="token punctuation">}</span><span class="token punctuation">;</span> 
    <span class="token keyword">int</span> outside<span class="token double-colon punctuation">::</span>inside<span class="token double-colon punctuation">::</span>y <span class="token operator">=</span> <span class="token number">5</span><span class="token punctuation">;</span>  

    <span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span> 
        outside A<span class="token punctuation">;</span> 
        outside<span class="token double-colon punctuation">::</span>inside B<span class="token punctuation">;</span> 

    <span class="token punctuation">}</span>
</code></pre>
</li>
</ul>
<h2 id="112-"><a name="112-" class="anchor-navigation-ex-anchor" href="#112-"><i class="fa fa-link" aria-hidden="true"></i></a>11.2. <code>:</code></h2>
<ul>
<li><strong>foreach</strong></li>
</ul>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">for</span><span class="token punctuation">(</span><span class="token keyword">int</span> item<span class="token operator">:</span>vector<span class="token punctuation">)</span><span class="token punctuation">{</span>

    <span class="token punctuation">}</span>
</code></pre>
<ul>
<li><strong>&#x7EE7;&#x627F;</strong></li>
<li><strong>&#x53C2;&#x6570;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;</strong></li>
</ul>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">class</span> <span class="token class-name">Father</span><span class="token punctuation">{</span>
<span class="token keyword">public</span><span class="token operator">:</span>
    <span class="token function">Father</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        cout <span class="token operator">&lt;&lt;</span> <span class="token string">&quot;father&quot;</span> <span class="token operator">&lt;&lt;</span> endl<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token comment">// &#x7EE7;&#x627F;</span>
<span class="token keyword">class</span> <span class="token class-name">Son</span><span class="token operator">:</span><span class="token base-clause"><span class="token keyword">public</span> <span class="token class-name">Father</span></span><span class="token punctuation">{</span>
<span class="token keyword">public</span><span class="token operator">:</span>
    <span class="token comment">// &#x53C2;&#x6570;&#x5316;&#x5217;&#x8868;</span>
    <span class="token function">Son</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">:</span><span class="token function">Father</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        cout <span class="token operator">&lt;&lt;</span> <span class="token string">&quot;son&quot;</span> <span class="token operator">&lt;&lt;</span> endl<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
</code></pre>
<h2 id="113-&#x53C2;&#x6570;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;"><a name="113-&#x53C2;&#x6570;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;" class="anchor-navigation-ex-anchor" href="#113-&#x53C2;&#x6570;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;"><i class="fa fa-link" aria-hidden="true"></i></a>11.3. &#x53C2;&#x6570;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;</h2>
<ul>
<li><strong>&#x521D;&#x59CB;&#x5316;&#x7236;&#x7C7B;&#x7684;&#x6784;&#x9020;&#x5668;</strong></li>
<li><strong>&#x521D;&#x59CB;&#x5316;<code>const</code>&#x53D8;&#x91CF;</strong></li>
<li><strong>&#x521D;&#x59CB;&#x5316;<code>var &amp;</code>&#x5F15;&#x7528;&#x53D8;&#x91CF;</strong></li>
</ul>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">class</span> <span class="token class-name">Father</span><span class="token punctuation">{</span>
<span class="token keyword">public</span><span class="token operator">:</span>
    <span class="token function">Father</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        cout <span class="token operator">&lt;&lt;</span> <span class="token string">&quot;father&quot;</span> <span class="token operator">&lt;&lt;</span> endl<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token keyword">class</span> <span class="token class-name">Son</span><span class="token operator">:</span><span class="token base-clause"><span class="token keyword">public</span> <span class="token class-name">Father</span></span><span class="token punctuation">{</span>
<span class="token keyword">public</span><span class="token operator">:</span>
    <span class="token keyword">int</span><span class="token operator">&amp;</span> a<span class="token punctuation">;</span>
    <span class="token keyword">const</span> <span class="token keyword">int</span> b<span class="token punctuation">;</span>
    <span class="token comment">// &#x53C2;&#x6570;&#x521D;&#x59CB;&#x5316;&#x5217;&#x8868;</span>
    <span class="token function">Son</span><span class="token punctuation">(</span>a<span class="token punctuation">,</span>b<span class="token punctuation">)</span><span class="token operator">:</span><span class="token function">Father</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token function">a</span><span class="token punctuation">(</span>a<span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token function">b</span><span class="token punctuation">(</span>b<span class="token punctuation">)</span><span class="token punctuation">{</span>
        cout <span class="token operator">&lt;&lt;</span> <span class="token string">&quot;son&quot;</span> <span class="token operator">&lt;&lt;</span> endl<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
</code></pre>
<h1 id="12-include"><a name="12-include" class="anchor-navigation-ex-anchor" href="#12-include"><i class="fa fa-link" aria-hidden="true"></i></a>12. include</h1>
<ul>
<li><code>#include&lt;&gt;</code> :<strong>&#x53EA;&#x4ECE;&#x4ECE;&#x300C;&#x6807;&#x51C6;&#x5E93;&#x5934;&#x6587;&#x4EF6;&#x76EE;&#x5F55;&#x300D;&#x4E0B;&#x641C;&#x7D22;</strong>&#xFF0C;&#x5BF9;&#x4E8E;&#x6807;&#x51C6;&#x5E93;&#x6587;&#x4EF6;&#x641C;&#x7D22;&#x6548;&#x7387;&#x5FEB;&#x3002;</li>
<li><code>#include&quot;&quot;</code> :<strong>&#x9996;&#x5148;&#x4ECE;&#x300C;&#x5F53;&#x524D;&#x6E90;&#x6587;&#x4EF6;&#x76EE;&#x5F55;&#x300D;&#x5F00;&#x59CB;&#x641C;&#x7D22;&#xFF0C;&#x7136;&#x540E;&#x641C;&#x7D22;&#x6807;&#x51C6;&#x5E93;</strong>&#xFF0C;&#x5BF9;&#x4E8E;&#x81EA;&#x5B9A;&#x4E49;&#x6587;&#x4EF6;&#x641C;&#x7D22;&#x6BD4;&#x8F83;&#x5FEB;&#x3002;</li>
</ul>
<h1 id="13-type-3"><a name="13-type-3" class="anchor-navigation-ex-anchor" href="#13-type-3"><i class="fa fa-link" aria-hidden="true"></i></a>13. type-3</h1>
<h2 id="131-&#x603B;&#x7ED3;type-3"><a name="131-&#x603B;&#x7ED3;type-3" class="anchor-navigation-ex-anchor" href="#131-&#x603B;&#x7ED3;type-3"><i class="fa fa-link" aria-hidden="true"></i></a>13.1. &#x603B;&#x7ED3;<code>type-3</code></h2>
<table>
<thead>
<tr>
<th>&#x540D;&#x79F0;</th>
<th>&#x4F5C;&#x7528;</th>
<th>&#x6CE8;&#x610F;</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>typedef</code></td>
<td>&#x7ED9;&#x53D8;&#x91CF;<code>A</code>&#x8D4B;&#x4E88;&#x4E00;&#x4E2A;&#x522B;&#x540D;<code>B</code></td>
<td><strong>1)<code>A</code>&#x5F53;&#x524D;&#x4F5C;&#x7528;&#x57DF;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x7684;</strong> <br> <strong>2)<code>B</code>&#x53EA;&#x5728;&#x5F53;&#x524D;&#x4F5C;&#x7528;&#x57DF;&#x6709;&#x6548;</strong></td>
</tr>
<tr>
<td><code>typeid()</code></td>
<td>&#x83B7;&#x53D6;&#x7C7B;&#x578B;&#x4FE1;&#x606F;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;<strong>&#x5BF9;&#x8C61;&#x539F;&#x59CB;&#x6A21;&#x677F;&#x7684;&#x4FE1;&#x606F;</strong></td>
<td><strong>&#x6CDB;&#x578B;</strong></td>
</tr>
<tr>
<td><code>typename</code></td>
<td>1&#xFF09;<strong>&#x58F0;&#x660E;&#x6CDB;&#x578B;&#x7C7B;&#x578B;</strong>&#xFF1B;<br> 2&#xFF09;<strong>&#x58F0;&#x660E;&#x6CDB;&#x578B;&#x5185;&#x5D4C;&#x7C7B;&#x578B;</strong></td>
<td>&#x4E0B;&#x9762;&#x89E3;&#x91CA;</td>
</tr>
</tbody>
</table>
<h2 id="132-typeid"><a name="132-typeid" class="anchor-navigation-ex-anchor" href="#132-typeid"><i class="fa fa-link" aria-hidden="true"></i></a>13.2. <code>typeid()</code></h2>
<pre class="language-"><code class="lang-cpp"><span class="token comment">// &#x67E5;&#x770B;&#x7C7B;&#x578B;</span>
    <span class="token keyword">typedef</span> <span class="token keyword">int</span> FUCK<span class="token punctuation">;</span>
    <span class="token keyword">int</span> var<span class="token punctuation">;</span>
    <span class="token keyword">const</span> type_info <span class="token operator">&amp;</span> infoInt <span class="token operator">=</span> <span class="token keyword">typeid</span><span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">const</span> type_info <span class="token operator">&amp;</span> infoDef <span class="token operator">=</span> <span class="token keyword">typeid</span><span class="token punctuation">(</span>FUCK<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">const</span> type_info <span class="token operator">&amp;</span> infoVar <span class="token operator">=</span> <span class="token keyword">typeid</span><span class="token punctuation">(</span>var<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">// &#x67E5;&#x770B;&#x4FE1;&#x606F;</span>
    info<span class="token punctuation">.</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &#x7C7B;&#x578B;&#x539F;&#x59CB;&#x6A21;&#x677F;&#x7684;&#x540D;&#x79F0;</span>
    info<span class="token punctuation">.</span><span class="token function">hash_code</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// &#x7C7B;&#x578B;&#x539F;&#x59CB;&#x6A21;&#x677F;&#x7684;&#x54C8;&#x5E0C;&#x7801;</span>

    <span class="token comment">// &#x67E5;&#x770B;&#x4E24;&#x4E2A;&#x7C7B;&#x578B;&#x662F;&#x5426;&#x4E00;&#x6837;</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>infoInt <span class="token operator">==</span> infoDef<span class="token punctuation">)</span>
</code></pre>
<blockquote>
<p>[!note|style:flat]
1 <strong><code>infoInt,infoDef,infoVar</code>&#x90FD;&#x662F;&#x4E00;&#x6837;&#x7684;&#xFF0C;&#x4ED6;&#x4EEC;&#x7684;&#x539F;&#x59CB;&#x6A21;&#x677F;&#x90FD;&#x662F;<code>int</code></strong>&#x3002;</p>
<p>2 <strong>&#x6CDB;&#x578B;&#x8BC6;&#x522B;&#x7C7B;&#x578B;</strong></p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">template</span><span class="token operator">&lt;</span><span class="token keyword">typename</span> <span class="token class-name">T</span><span class="token operator">&gt;</span>
<span class="token keyword">void</span> <span class="token function">print</span><span class="token punctuation">(</span>T<span class="token operator">&amp;</span> a<span class="token punctuation">)</span><span class="token punctuation">{</span>
   <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token keyword">typeid</span><span class="token punctuation">(</span>a<span class="token punctuation">)</span> <span class="token operator">==</span> <span class="token keyword">typeid</span><span class="token punctuation">(</span><span class="token keyword">int</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
       cout <span class="token operator">&lt;&lt;</span> <span class="token string">&quot;True&quot;</span> <span class="token operator">&lt;&lt;</span> endl<span class="token punctuation">;</span>
   <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<p>3 <strong>&#x65E0;&#x6CD5;&#x786E;&#x5B9A;&#x7EE7;&#x627F;&#x539F;&#x59CB;&#x7C7B;&#x578B;&#xFF0C;&#x8F93;&#x51FA;&#x4E3A;<code>Father</code>&#xFF1B;<code>s</code>&#x88AB;&#x9996;&#x5148;<code>Father</code>&#x9759;&#x7ED1;&#x5B9A;&#x4E86;&#x3002;</strong></p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">class</span> <span class="token class-name">Father</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token keyword">class</span> <span class="token class-name">Son</span> <span class="token operator">:</span> <span class="token base-clause"><span class="token keyword">public</span> <span class="token class-name">Father</span></span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    Father <span class="token operator">*</span> s <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token function">Son</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    cout <span class="token operator">&lt;&lt;</span> <span class="token keyword">typeid</span><span class="token punctuation">(</span>s<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">name</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">&lt;&lt;</span> endl<span class="token punctuation">;</span>
    <span class="token keyword">delete</span> son<span class="token punctuation">;</span>
    <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre>
</blockquote>
<h2 id="133-typename"><a name="133-typename" class="anchor-navigation-ex-anchor" href="#133-typename"><i class="fa fa-link" aria-hidden="true"></i></a>13.3. <code>typename</code></h2>
<ul>
<li><p><strong>&#x58F0;&#x660E;&#x6CDB;&#x578B;&#x7C7B;&#x578B;</strong></p>
<pre class="language-"><code class="lang-cpp">  <span class="token comment">// &#x6CDB;&#x578B;</span>
        <span class="token keyword">template</span><span class="token operator">&lt;</span><span class="token keyword">typename</span> <span class="token class-name">T</span><span class="token operator">&gt;</span>
        <span class="token keyword">class</span> <span class="token class-name">Test</span><span class="token punctuation">{</span>
        <span class="token keyword">public</span><span class="token operator">:</span>
            <span class="token keyword">void</span> <span class="token function">print</span><span class="token punctuation">(</span><span class="token keyword">const</span> T <span class="token operator">&amp;</span> a<span class="token punctuation">)</span><span class="token punctuation">{</span>
                cout <span class="token operator">&lt;&lt;</span> a <span class="token operator">&lt;&lt;</span> endl<span class="token punctuation">;</span> 
            <span class="token punctuation">}</span>
        <span class="token punctuation">}</span><span class="token punctuation">;</span>

        <span class="token keyword">int</span> <span class="token function">main</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
            Test<span class="token operator">&lt;</span><span class="token keyword">int</span><span class="token operator">&gt;</span> test<span class="token punctuation">;</span>

            test<span class="token punctuation">.</span><span class="token function">print</span><span class="token punctuation">(</span><span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

            <span class="token keyword">return</span> <span class="token number">0</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
</code></pre>
<blockquote>
<p>[!note|style:flat]
<strong><code>Test<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>int</span><span class="token punctuation">&gt;</span></span> test;</code>&#x662F;&#x5728;&#x7F16;&#x8BD1;&#x65F6;&#x786E;&#x5B9A;&#xFF0C;&#x5C5E;&#x4E8E;&#x9759;&#x6001;&#x7ED1;&#x5B9A;&#x3002;</strong></p>
</blockquote>
</li>
<li><p><strong>&#x58F0;&#x660E;&#x6CDB;&#x578B;&#x5185;&#x5D4C;&#x7C7B;&#x578B;</strong></p>
<ul>
<li><strong>&#x6CDB;&#x578B;&#xFF1A;&#x5927;&#x524D;&#x63D0;</strong></li>
<li><p><strong>&#x5185;&#x5D4C;&#xFF1A;&#x5728;&#x7C7B;&#x7684;&#x5185;&#x90E8;&#x5B9A;&#x4E49;&#x7C7B;&#x578B;&#x3002;</strong></p>
<pre class="language-"><code class="lang-cpp">  <span class="token keyword">class</span> <span class="token class-name">Car</span><span class="token punctuation">{</span>
    <span class="token keyword">public</span><span class="token operator">:</span>
        <span class="token comment">// &#x7C7B;&#x578B;&#x522B;&#x540D;</span>
        <span class="token keyword">typedef</span> <span class="token keyword">float</span> Speed<span class="token punctuation">;</span>
        <span class="token comment">// &#x5185;&#x90E8;&#x7C7B;</span>
        <span class="token keyword">class</span> <span class="token class-name">Wheel</span><span class="token punctuation">{</span>
        <span class="token punctuation">}</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">;</span>
</code></pre>
<p>  <span style="color:red;font-weight:bold"> &#x5F53;&#x4F7F;&#x7528;&#x6CDB;&#x578B;&#x7684;&#x5185;&#x5D4C;&#x7C7B;&#x578B;&#x5B9A;&#x4E49;&#x53D8;&#x91CF;&#x65F6;&#xFF0C;&#x9700;&#x8981;&#x5229;&#x7528;<code>typename</code>&#x8FDB;&#x884C;&#x8BF4;&#x660E;&#xFF0C;&#x5426;&#x5219;&#x7F16;&#x8BD1;&#x5668;&#x4E0D;&#x77E5;&#x9053;&#x8FD9;&#x4E2A;&#x662F;&#x7C7B;&#x578B;&#x8FD8;&#x662F;<code>static</code>&#x53D8;&#x91CF;&#x3002;</span></p>
<pre class="language-"><code class="lang-cpp">  <span class="token keyword">class</span> <span class="token class-name">Car</span><span class="token punctuation">{</span>
    <span class="token keyword">public</span><span class="token operator">:</span>
        <span class="token comment">// &#x7C7B;&#x578B;&#x522B;&#x540D;</span>
        <span class="token keyword">typedef</span> <span class="token keyword">float</span> Speed<span class="token punctuation">;</span>
        <span class="token comment">// &#x5185;&#x90E8;&#x7C7B;</span>
        <span class="token keyword">class</span> <span class="token class-name">Wheel</span><span class="token punctuation">{</span>
        <span class="token punctuation">}</span><span class="token punctuation">;</span>

        <span class="token keyword">static</span> <span class="token keyword">float</span> price<span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">;</span>

    <span class="token keyword">template</span><span class="token operator">&lt;</span><span class="token keyword">typename</span> <span class="token class-name">T</span><span class="token operator">&gt;</span>
    <span class="token keyword">class</span> <span class="token class-name">PrivateCar</span><span class="token punctuation">{</span>
        <span class="token keyword">public</span><span class="token operator">:</span>
        <span class="token comment">// &#x5B9A;&#x4E49;&#x53D8;&#x91CF;</span>
        <span class="token keyword">typename</span> <span class="token class-name">T</span><span class="token double-colon punctuation">::</span>Speed v<span class="token punctuation">;</span>
        <span class="token keyword">typename</span> <span class="token class-name">T</span><span class="token double-colon punctuation">::</span>Wheel wheels<span class="token punctuation">;</span>
        <span class="token keyword">float</span> <span class="token function">getPrice</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
            <span class="token comment">// &#x53D8;&#x91CF;</span>
            <span class="token keyword">return</span> T<span class="token double-colon punctuation">::</span>price<span class="token punctuation">;</span> 
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">;</span>
</code></pre>
<blockquote>
<p>[!note|style:flat]
<strong>&#x4E0D;&#x7528;<code>typename</code>&#x7684;&#x5217;&#x5916;&#x60C5;&#x51B5;</strong></p>
<pre class="language-"><code class="lang-cpp"><span class="token keyword">template</span><span class="token operator">&lt;</span><span class="token keyword">class</span> <span class="token class-name">T</span><span class="token operator">&gt;</span>
<span class="token keyword">class</span> <span class="token class-name">Derived</span><span class="token operator">:</span> <span class="token base-clause"><span class="token keyword">public</span> <span class="token class-name">Base</span><span class="token operator">&lt;</span><span class="token class-name">T</span><span class="token operator">&gt;</span><span class="token double-colon punctuation">::</span>&#x5185;&#x90E8;&#x7C7B;&#x578B;</span>
<span class="token punctuation">{</span>
  <span class="token function">Derived</span><span class="token punctuation">(</span><span class="token keyword">int</span> x<span class="token punctuation">)</span> <span class="token operator">:</span> Base<span class="token operator">&lt;</span>T<span class="token operator">&gt;</span><span class="token double-colon punctuation">::</span>&#x5185;&#x90E8;&#x7C7B;&#x578B;<span class="token punctuation">(</span>x<span class="token punctuation">)</span>
  <span class="token punctuation">{</span>
  <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
</blockquote>
</li>
</ul>
</li>
</ul>
<h1 id="14-privateprotectedpublic"><a name="14-privateprotectedpublic" class="anchor-navigation-ex-anchor" href="#14-privateprotectedpublic"><i class="fa fa-link" aria-hidden="true"></i></a>14. private/protected/public</h1>
<h2 id="141-&#x7C7B;&#x7684;&#x5185;&#x90E8;&#x5BF9;&#x5916;"><a name="141-&#x7C7B;&#x7684;&#x5185;&#x90E8;&#x5BF9;&#x5916;" class="anchor-navigation-ex-anchor" href="#141-&#x7C7B;&#x7684;&#x5185;&#x90E8;&#x5BF9;&#x5916;"><i class="fa fa-link" aria-hidden="true"></i></a>14.1. &#x7C7B;&#x7684;&#x5185;&#x90E8;&#x5BF9;&#x5916;</h2>
<blockquote>
<p>[!note]
<strong>&#x9ED8;&#x8BA4;&#x4FEE;&#x9970;&#x4E3A;<code>private</code></strong></p>
</blockquote>
<table>
<thead>
<tr>
<th>&#x4FEE;&#x9970;&#x6210;&#x5458;</th>
<th>private</th>
<th>protected</th>
<th>public</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x5916;&#x90E8;&#x80FD;&#x5426;&#x8BBF;&#x95EE;</td>
<td>&#x4E0D;&#x884C;</td>
<td>&#x4E0D;&#x884C;</td>
<td>&#x53EF;&#x4EE5;</td>
</tr>
</tbody>
</table>
<h2 id="142-&#x7EE7;&#x627F;"><a name="142-&#x7EE7;&#x627F;" class="anchor-navigation-ex-anchor" href="#142-&#x7EE7;&#x627F;"><i class="fa fa-link" aria-hidden="true"></i></a>14.2. &#x7EE7;&#x627F;</h2>
<blockquote>
<p>[!note]
<strong>&#x9ED8;&#x8BA4;&#x7EE7;&#x627F;&#x4E3A;<code>private</code></strong></p>
</blockquote>
<h3 id="1421-&#x5B50;&#x7C7B;&#x5185;&#x90E8;&#x5BF9;&#x7236;&#x7C7B;&#x7684;&#x8BBF;&#x95EE;"><a name="1421-&#x5B50;&#x7C7B;&#x5185;&#x90E8;&#x5BF9;&#x7236;&#x7C7B;&#x7684;&#x8BBF;&#x95EE;" class="anchor-navigation-ex-anchor" href="#1421-&#x5B50;&#x7C7B;&#x5185;&#x90E8;&#x5BF9;&#x7236;&#x7C7B;&#x7684;&#x8BBF;&#x95EE;"><i class="fa fa-link" aria-hidden="true"></i></a>14.2.1. &#x5B50;&#x7C7B;&#x5185;&#x90E8;&#x5BF9;&#x7236;&#x7C7B;&#x7684;&#x8BBF;&#x95EE;</h3>
<table>
<thead>
<tr>
<th>&#x4FEE;&#x9970;&#x7236;&#x7C7B;&#x6210;&#x5458;</th>
<th>private</th>
<th>protected</th>
<th>public</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x5B50;&#x7C7B;&#x80FD;&#x5426;&#x8BBF;&#x95EE;</td>
<td>&#x4E0D;&#x884C;</td>
<td>&#x53EF;&#x4EE5;</td>
<td>&#x53EF;&#x4EE5;</td>
</tr>
</tbody>
</table>
<blockquote>
<p>[!note|style:flat]
<strong>&#x7EE7;&#x627F;&#x9650;&#x5B9A;&#x5BF9;&#x5B50;&#x7C7B;&#x8BBF;&#x95EE;&#x7236;&#x7C7B;&#xFF0C;&#x6CA1;&#x6709;&#x4E00;&#x4E22;&#x4E22;&#x7684;&#x5F71;&#x54CD;&#xFF0C;&#x8BBF;&#x95EE;&#x6743;&#x9650;&#x548C;&#x4E0A;&#x9762;&#x4E00;&#x6837;&#x3002;</strong></p>
</blockquote>
<h3 id="1422-&#x5B50;&#x7C7B;&#x7684;&#x7236;&#x7C7B;&#x6210;&#x5458;&#x5BF9;&#x5916;"><a name="1422-&#x5B50;&#x7C7B;&#x7684;&#x7236;&#x7C7B;&#x6210;&#x5458;&#x5BF9;&#x5916;" class="anchor-navigation-ex-anchor" href="#1422-&#x5B50;&#x7C7B;&#x7684;&#x7236;&#x7C7B;&#x6210;&#x5458;&#x5BF9;&#x5916;"><i class="fa fa-link" aria-hidden="true"></i></a>14.2.2. &#x5B50;&#x7C7B;&#x7684;&#x7236;&#x7C7B;&#x6210;&#x5458;&#x5BF9;&#x5916;</h3>
<table>
<thead>
<tr>
<th>&#x4FEE;&#x9970;&#x7EE7;&#x627F;</th>
<th>private</th>
<th>protected</th>
<th>public</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x5B50;&#x7C7B;&#x4E2D;&#x7684;&#x7236;&#x7C7B;&#x6210;&#x5458;</td>
<td><code>public</code>&#x53D8;<code>private</code> <br> <code>protected</code>&#x53D8;<code>private</code></td>
<td><code>public</code>&#x53D8;<code>protected</code></td>
<td>&#x4FDD;&#x6301;&#x539F;&#x6837;</td>
</tr>
</tbody>
</table>
<h1 id="15-a--a--b&#x4E0E;a--b"><a name="15-a--a--b&#x4E0E;a--b" class="anchor-navigation-ex-anchor" href="#15-a--a--b&#x4E0E;a--b"><i class="fa fa-link" aria-hidden="true"></i></a>15. <code>a = a + b</code>&#x4E0E;<code>a += b</code></h1>
<p><strong>&#x5BF9;&#x4E8E;<code>a = a + b</code>&#x800C;&#x8A00;&#xFF0C;&#x53EF;&#x4EE5;&#x7B49;&#x4EF7;&#x4E8E;&#xFF1A;</strong></p>
<blockquote>
<p>[!tip]</p>
<pre class="language-"><code class="lang-cpp">temp <span class="token operator">=</span> a<span class="token punctuation">;</span>
temp <span class="token operator">+=</span> b<span class="token punctuation">;</span>
a <span class="token operator">=</span> temp<span class="token punctuation">;</span>
</code></pre>
<ul>
<li><span style="color:red;font-weight:bold"> <code>temp</code>&#x5C31;&#x662F;&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#x4E2D;&#x7684;&#x90A3;&#x4E2A;&#x300C;&#x5E38;&#x6027;&#x4E2D;&#x95F4;&#x53D8;&#x91CF;&#x300D;&#x3002; &lt;/span</span></li>
<li><strong>&#x5C31;&#x6548;&#x7387;&#x800C;&#x8A00;<code>a += b</code>&#x6BD4;&#x8F83;&#x5FEB;&#x3002;</strong></li>
</ul>
</blockquote>
<h1 id="16-&#x5B8F;&#x53D8;&#x91CF;"><a name="16-&#x5B8F;&#x53D8;&#x91CF;" class="anchor-navigation-ex-anchor" href="#16-&#x5B8F;&#x53D8;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>16. &#x5B8F;&#x53D8;&#x91CF;</h1>
<table>
<thead>
<tr>
<th>&#x540D;&#x79F0;</th>
<th>&#x63CF;&#x8FF0;</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>_LINE_</code></td>
<td>&#x8FD9;&#x4F1A;&#x5728;&#x7A0B;&#x5E8F;&#x7F16;&#x8BD1;&#x65F6;&#x5305;&#x542B;&#x5F53;&#x524D;&#x884C;&#x53F7;</td>
</tr>
<tr>
<td><code>_FILE_</code></td>
<td>&#x8FD9;&#x4F1A;&#x5728;&#x7A0B;&#x5E8F;&#x7F16;&#x8BD1;&#x65F6;&#x5305;&#x542B;&#x5F53;&#x524D;&#x6587;&#x4EF6;&#x540D;</td>
</tr>
<tr>
<td><code>_DATE_</code></td>
<td>&#x8FD9;&#x4F1A;&#x5305;&#x542B;&#x4E00;&#x4E2A;&#x5F62;&#x5F0F;&#x4E3A; <code>month/day/year</code></td>
</tr>
<tr>
<td><code>_TIME_</code></td>
<td>&#x8FD9;&#x4F1A;&#x5305;&#x542B;&#x4E00;&#x4E2A;&#x5F62;&#x5F0F;&#x4E3A; <code>hour:minute:second</code> &#x7684;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x5B83;&#x8868;&#x793A;&#x7A0B;&#x5E8F;&#x88AB;&#x7F16;&#x8BD1;&#x7684;&#x65F6;&#x95F4;&#x3002;</td>
</tr>
<tr>
<td><code>__cplusplus</code></td>
<td>&#x662F;<code>c++</code>&#x8FDB;&#x884C;&#x7F16;&#x8BD1;&#xFF0C;&#x8FD8;&#x662F;<code>c</code>&#x8BED;&#x8A00;&#x8FDB;&#x884C;&#x7F16;&#x8BD1;</td>
</tr>
</tbody>
</table>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="foundation_withNum.html" class="navigation navigation-prev " aria-label="Previous page: 一、基础概念">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="point_reference_withNum.html" class="navigation navigation-next " aria-label="Next page: 三、指针与引用">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"二、关键字","level":"2.1.2","depth":2,"next":{"title":"三、指针与引用","level":"2.1.3","depth":2,"path":"cpp/chapter/point_reference_withNum.md","ref":"cpp/chapter/point_reference_withNum.md","articles":[]},"previous":{"title":"一、基础概念","level":"2.1.1","depth":2,"path":"cpp/chapter/foundation_withNum.md","ref":"cpp/chapter/foundation_withNum.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-lunr","-search","search-pro-fixed","expandable-chapters-small","ancre-navigation","hide-element","code","splitter","insert-logo-link-website","-sharing","sharing-plus","prism","-highlight","flexible-alerts","lightbox","pageview-count","auto-scroll-table","katex-pro","favicon-absolute","sectionx","terminull-light","livereload"],"styles":{"website":"styles/website.css","ebook":"styles/ebook.css","pdf":"styles/pdf.css","mobi":"styles/mobi.css","epub":"styles/epub.css"},"pluginsConfig":{"prism":{"css":["prismjs/themes/prism-tomorrow.css"],"lang":{"flow":"typescript"}},"livereload":{},"splitter":{},"sharing-plus":{"qq":false,"all":["facebook","google","twitter","instapaper","linkedin","pocket","stumbleupon"],"douban":false,"facebook":true,"weibo":false,"instapaper":false,"whatsapp":false,"hatenaBookmark":false,"twitter":true,"messenger":false,"line":false,"vk":false,"pocket":true,"google":false,"viber":false,"stumbleupon":false,"qzone":false,"linkedin":false},"auto-scroll-table":{},"code":{"copyButtons":true},"terminull-light":{},"search-pro-fixed":{},"favicon-absolute":{"favicon":"image/ico.png","appleTouchIconPrecomposed152":"image/ico.png","appleTouchIconMore":{},"appleTouchIconPrecomposedMore":{}},"hide-element":{"elements":[".gitbook-link"]},"katex-pro":{},"fontsettings":{"theme":"white","family":"sans","size":2},"sectionx":{"tag":"b"},"lightbox":{"jquery":true,"sameUuid":false},"insert-logo-link-website":{"url":"image/logo.png","link":"https://space.bilibili.com/27206875","target":"_blank","style":"height: 230px"},"pageview-count":{},"ancre-navigation":{"showLevel":true,"associatedWithSummary":true,"mode":"float","printLog":false,"multipleH1":true,"float":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""},"pageTop":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""}},"expandable-chapters-small":{},"flexible-alerts":{"style":"callout","note":{"label":"Note","icon":"fa fa-info-circle","className":"info"},"tip":{"label":"Tip","icon":"fa fa-lightbulb-o","className":"tip"},"warning":{"label":"Warning","icon":"fa fa-exclamation-triangle","className":"warning"},"danger":{"label":"Attention","icon":"fa fa-ban","className":"danger"}},"sharing":{"qq":true,"all":["douban","facebook","google","instapaper","linkedin","twitter","weibo","messenger","qq","qzone","viber","whatsapp"],"douban":false,"facebook":false,"weibo":true,"whatsapp":false,"twitter":false,"pocket":false,"google":true,"qzone":false},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"海拉尔的三角","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"计算机笔记","links":{"sidebar":{"Github":"https://github.com/spite-triangle"}},"gitbook":"*"},"file":{"path":"cpp/chapter/keyword_withNum.md","mtime":"2021-09-14T15:43:12.498Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-09-14T15:43:23.052Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro-fixed/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro-fixed/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-insert-logo-link-website/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing-plus/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-flexible-alerts/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lightbox/js/lightbox.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-auto-scroll-table/plugin.js"></script>
        
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-terminull-light/terminull.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

